import 'package:chathouse/public/Global.dart';
import 'package:chathouse/util/SpUtil.dart';

class ApiConfigType {
  static const int TEST = 0; //测试环境
  static const int GRAY = 1; //预发环境
  static const int PRODUCT = 2; //线上环境
}

class ApiHost {
  //获取默认环境
  static int getDefaultSelectValue() {
    //获取选中的环境类型 默认选中的单选框的值 0测试 1预发布 2生产
    int typeValue = SpUtil.getInt(Keys.SELECTED_HOST_TYPE_KEY,
        defValue: ApiConfigType.PRODUCT);
    return typeValue;
  }

  static String getHostFromValue(int typeValue) {
    String inputHost = '';
    switch (typeValue) {
      case ApiConfigType.TEST: //测试
        inputHost = "https://noahsolutions.net/";
        break;
      case ApiConfigType.GRAY: //预发
        inputHost = "https://noahsolutions.net/";
        break;
      case ApiConfigType.PRODUCT: //生产
        inputHost = "https://noahsolutions.net/";
        break;
      default: //生产
        inputHost = "https://noahsolutions.net/";
        break;
    }
    return inputHost;
  }

  static int getHostFromStringValue(String typeValue) {
    int value = ApiConfigType.PRODUCT;
    //#todo
    // switch (typeValue) {
    //   case "https://test.management.api.o2o.mfoodapp.com/": //测试
    //     value = ApiConfigType.TEST;
    //     break;
    //   case "https://pre.management.api.o2o.mfoodapp.com/": //预发
    //     value = ApiConfigType.GRAY;
    //     break;
    //   case "https://management.api.o2o.mfoodapp.com/": //生产
    //     value = ApiConfigType.PRODUCT;
    //     break;
    //   default: //生产
    //     value = ApiConfigType.PRODUCT;
    //     break;
    // }
    return value;
  }
}
